package com.cx.proxy;

import lombok.Data;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @Author:cxy
 * @Date:2022/1/25 21:30
 */
@Data
public class MapperProxy implements InvocationHandler {
//
//    private SqlSession proxy;
//
//    public MapperProxy(Object proxy) {
//        this.proxy = proxy;
//    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (Object.class.equals(method.getDeclaringClass())) {
            return method.invoke(this, args);
        }

        System.out.println("excute sql by method name");
        return Arrays.toString(args);
    }
}
